﻿<link rel="stylesheet" type="text/css" href="include/tintuc.css" />
<style type="text/css">
	#h3tt{padding:0 0 0 10px;margin:0px; font-weight:bold; font-family:Tahoma, Geneva, sans-serif; color:#333; font-size:23px;}
	#h5tt{padding:0 0 0 10px;margin:20px 0px 5px;}
	</style>
<?php
require_once '/function/function.php';
require_once './library/config.php';
if(!isset($_GET['bt'])){		
if(!isset($_SESSION['user_id'])){

echo '<h3 id="h3tt"> Tin tức</h3><br/><br/><font id=cl color="#FF0000" size="4.5">Hãy <a href="index.php?pa=dangnhap">đăng nhập</a> để có thể xem tin tức theo chủ đề!!!</font><br/><br/>';
}
else{
?>
<h3 id="h3tt"> Tin tức</h3>
<h5 id="h5tt">Chủ đề</h5>
<ul class=tintuc>
<?php chudeList(); ?>
</ul>

<?php
}
?>
<?php
if(isset($_GET['tt'])){
$cd=$_GET['tt'];
$queryString = "";
?>
<div class="news">
    	<ul>        
        <?php //tintuc
			$rowsPerPage = 5;
			if($_GET['tt']!='0')
			$sql="Select * From tbl_tintuc where Chude_id='$cd'";
			else if($_GET['tt']=='-1') $sql=""; else $sql="Select * From tbl_tintuc";
			$result=dbQuery(getPagingQuery($sql, $rowsPerPage));
			if(@mysql_num_rows($result)>0){
				while($row=mysql_fetch_array($result)){
					$time="";?>
					<li>
            	<div class="n2img">
                	<a title="<?php echo $row['Ten'];?>" href="index.php?action=tintuc&bt=<?php echo $row['Tintuc_id'];?>">
                		<img width="132" height="99" alt="<?php echo $row['Ten'];?>" src="<?php echo WEB_ROOT . TINTUC_IMAGE_DIR . $row['Image'];?>">
            		</a>
                </div>
                <div class="n2title"><a title="<?php echo $row['Ten'];?>" href="index.php?action=tintuc&bt=<?php echo $row['Tintuc_id'];?>"><?php echo $row['Ten'];?></a></div>

                <div class="n2intro"><p><?php echo $row['Tieude'];?></p></div>
                
                <div class="n2update">Cập nhật: <span><?php
				$items=array();
				$items=explode("-",$row['Ngaydang']);
				for($i=0;$i<count($items);$i++){
					$year=$items[0];
					$month=$items[1];
					$day=$items[2];
				}
				$time=$day."/".$month."/".$year;
				  echo $time;?></span></div>
            </li>
            		
		<?php
				}
				echo getPagingLink($sql, $rowsPerPage, "pa=tintuc&tt=$cd");
			}else if($_GET['tt']=='-1') echo '<div><p></p></div>';
					else
						echo '<div><p>Đang cập nhật!!</p></div>';
	}?>
	</ul>    
    </div> <!--ket thuc news4-->
	<?php

} else{//bantin
	function dinhdangNgay($NhapNgay){
	$items=array();
	$items=explode("-",$NhapNgay);
	for($i=0;$i<count($items);$i++){
		$year=$items[0];
		$month=$items[1];
		$day=$items[2];
		}
	return $time=$day."/".$month."/".$year;
	}
	$mbt=$_GET['bt'];
	?>
	<div class="bantin">
    <?php 
	$mysql_str=mysql_query("Select * From tbl_tintuc Where Tintuc_id=".$mbt);	
	$row=mysql_fetch_assoc($mysql_str);
	if($row>0){
?>
    <div class="newsacs">Ngày đưa tin: <?php echo dinhdangNgay($row['Ngaydang']);?></div>
   
        <div class="atclear"></div>
 
    <div class="newstitle"><h1><?php echo $row['Ten'];?></h1></div>
    <div class="newsintro"><p><?php echo $row['Tieude'];?></p></div>
        <div class="newscontent">
    <?php echo $row['Noidung']; $chude=$row['Chude_id']?>
    <p style="text-align: right;" class="Normal">Theo <em><strong><?php echo $row['Tacgia'];?></strong></em></p>
<p><strong></strong></p></div>
        
        <div class="tinlienquan">Các tin liên quan</div>
    <div class="tinkhac" id="tabs">
    	<ul>
    	<?php $strSQL=mysql_query("Select * From tbl_tintuc Where Chude_id =".$chude." And Tintuc_id <> ".$mbt);
			if(@mysql_num_rows($strSQL)>0){
				while($row=mysql_fetch_array($strSQL)){
		?>
    	
                	<li><a title="<?php echo $row['Ten'];?>" href="bantin.php?bt=<?php echo $row['Tintuc_id'];?>"><?php echo $row['Ten'];?></a> - <span>[<?php echo dinhdangNgay($row['Ngaydang']);?>]</span></li>
    	  <?php
                }
           }else{
				echo "<li>Đang cập nhật.</li>";
			}?>
        </ul>
    </div>
        
  <div class="tinkhac" id="tabs">
        <div id="tittle_differ">Các tin khác</div>
        
        <div class="tkhac" id="tabs_1">
	    	<ul>
            <?php $strSQL=mysql_query("Select * From tbl_tintuc Where  Chude_id Not Like '%".$chude."%'");
			if(@mysql_num_rows($strSQL)>0){
				while($row=mysql_fetch_array($strSQL)){
		?>
    	
                	<li><a title="<?php echo $row['Ten'];?>" href="index.php?action=tintuc&bt=<?php echo $row['Tintuc_id'];?>"><?php echo $row['Ten'];?></a> - <span>[<?php echo dinhdangNgay($row['Ngaydang']);?>]</span></li>
    	  <?php
                }
           }else{
				echo "<li>Hiện chưa có thông tin này.</li>";
			}?>
            </ul>
       </div>
    </div>
   <?php }else{?>
		<div><?php echo die("Lỗi:".mysql_error());?></div>
<?php	}
?>
</div> 
<?php		
	}
		?>
        	
		        